//
//  PersonalPageViewController.m
//  KeleAppProject
//
//  Created by Cen Zhou on 2018/1/18.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "PersonalPageViewController.h"
#import "ListTableViewCell.h"
#import "PersonHeaderView.h"

static NSString *personlaCell = @"personlaCell";
@interface PersonalPageViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) PersonHeaderView *headerView;
@end

@implementation PersonalPageViewController




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self loadTableView];
    
}


// loadTableView
- (void)loadTableView{
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0,KLScreenW,KLScreenH) style:UITableViewStylePlain];
    if (@available(iOS 11.0, *)) {
        tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

    tableView.backgroundColor = KLColor_C1;
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.showsVerticalScrollIndicator = NO;
    tableView.showsHorizontalScrollIndicator = NO;
    tableView.sectionFooterHeight = 10*HEIGHT;
    tableView.sectionHeaderHeight = 0;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    [self.view addSubview:tableView];
    self.tableView = tableView;
}

#pragma mark ----delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 8;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:personlaCell];
    if (!cell) {
        cell = [[ListTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:personlaCell type:nil];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //    cell.backgroundColor = [UIColor purpleColor];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 110*HEIGHT;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    self.headerView = [[PersonHeaderView alloc]initWithFrame:CGRectMake(0, 0, KLScreenW, 210*HEIGHT)];
    self.headerView.delegateSignal = [RACSubject subject];
    [self.headerView.delegateSignal subscribeNext:^(id x) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    return self.headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 210*HEIGHT;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
